Auth()
//r_type判断用户注册类型
var r_type = globalFun.GetQueryString('v_type');

//创建活动
$('#creat_active').on('click', function() {
	$(this).addClass('lalala')
	$('#home').hide();
	$('#new_active').show();

})
//返回首页
$('#v_home').on('click', function() {
	$('#creat_active').removeClass('lalala')
	$('#home').show();
	$('#new_active').hide();

})
//返回我的活动
$('#v_active').on('click', function() {
	ActiveList(1, '0', true)
	$('#team_active').show();
	$('#people_list').hide();

})
//导航切换
$('.left_type p').on('click', function() {
	$(this).addClass('choose');
	$(this).siblings().removeClass('choose');
	var x = $(this).index();
	$('#m_right').children('div').eq(x).css('display', 'block');
	$('#m_right').children('div').eq(x).siblings().css('display', 'none')
})
//获取用户信息
//我的首页*********************************************************************************************
var mineObj = {
	loginName: name,
	uuid: uuid,
	loginType: is_team,
	loginId: id
}
$.ajax({
	type: "post",
	url: apicom + "/user/getMemberInfo",
	async: false,
	data: mineObj,
	success: function(res) {
		var info = res.data.memberInfo.teamInfo;
		var info_1 = res.data.teamInfo;
		$('.user_img img').attr('src', res.data.memberInfo.imgUrl);
		$('.name').text(info.name);
		$('.user_num').text(info.number);
		$('.user_creattime').text(info_1.createdTime);
		$('.user_logintime').text(info_1.loginTime);
		$('.user_phone').text(info.telphone);
		$('.user_name').text(info.username);
		$('.user_mail').text(info.mail);
		$('.user_address').text(info.address);
		$('td').eq(0).text(info_1.inTeam + '人');
		$('td').eq(1).text(info_1.auditTeam + '人');
		$('td').eq(2).text(info_1.hour + '个小时');
		$('td').eq(3).text(info_1.initNum + '次');
		$('td').eq(4).html(info_1.partNum + '次');
		$('.t_userName').text('用户名:' + info.username);
		$('.t_userNum').text('团队编号:' + info.number);
		$('#v_username').val(info.name);
		$('#competent_name').val(info.supervisorName);
		$('#v_address').val(info.address);
		$('#competent_num').val(info.teamNum);
		$('#description').val(info.description);
		$('#contacts_name').val(info.linkName);
		$('#contacts_phone').val(info.telphone);
		$('#contacts_qq').val(info.linkQq);
		$('#person_name').val(info.personName);
		$('#person_IDcard').val(info.person_idcard);
		$('#person_phone').val(info.personPhone);
		longitude = info.longitude;
		latitude = info.latitude;
		$("#competent_type").find("option[value='" + info.supervisorType + "']").attr("selected", true);

		//服务类别
		var server_type = $("#v_server_type input"); //获取所有的复选框值
		//放的复选框的值为字符串类型
		var express = info.serviceType.split(',');
		for(var i = 0; i < express.length; i++) {
			$.each(server_type, function(j, checkbox) {
				//获取复选框的value属性
				var checkValue = $(checkbox).val();
				if(express[i] == checkValue) {
					$(checkbox).attr("checked", true);
				}
			})
		}
		$('#vt_img').attr('src', res.data.memberInfo.imgUrl)

	},
	error: function(err) {
		console.log(err)
	}
});
//新建活动************************************************************************
var a_username;
var bol0 = false;
$("#a_username").on('blur', function() {
	if($("#a_username").val() == '') {
		$(this).next().text('活动名称不能为空').css('color', 'red').css('display', 'block');
		bol0 = false;
	} else {
		a_username = $("#a_username").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		bol0 = true;
	};
});
//志愿团体描述;
var hd_description;
var bol10 = false;
$("#hd_description").on('change', function() {
	if($("#hd_description").val() == '') {
		$(this).next().text('志愿团体不能为空').css('color', 'red').css('display', 'block');
		bol10 = false;
	} else {
		hd_description = $("#hd_description").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		bol10 = true;
	};
});
//详细地址
var a_address;
var bol1 = false;
$("#a_address").on('blur', function() {
	if($("#a_address").val() == '') {
		$(this).next().text('详细地址不能为空').css('color', 'red').css('display', 'block');
		bol1 = false;
	} else {
		a_address = $("#a_address").val();
		bol1 = true;
	};
});
//活动时间
var atime_k;
var bol2 = false;
$("#atime_k").on('blur', function() {
	if($("#atime_k").val() == '') {
		$(this).next().next().text('活动开始时间不能为空').css('color', 'red').css('display', 'block');
		bol2 = false;
	} else {
		atime_k = $("#atime_k").val();
		$(this).next().next().hide();
		bol2 = true;
	};
});
var atime_j;
var bol3 = false;
$("#atime_j").on('blur', function() {
	if($("#atime_j").val() == '') {
		$(this).next().text('活动结束时间不能为空').css('color', 'red').css('display', 'block');
		bol3 = false;
	} else {
		atime_j = $("#atime_j").val();
		$(this).next().hide()
		bol3 = true;
	};
});
//服务时间
var stime_k;
var bo4 = false;
$("#stime_k").on('blur', function() {
	if($("#stime_k").val() == '') {
		$(this).next().next().text('服务开始时间不能为空').css('color', 'red').css('display', 'block');
		bol4 = false;
	} else {
		stime_k = $("#stime_k").val();
		$(this).next().next().hide();
		bol4 = true;
	};
});
var stime_j;
var bol5 = false;
$("#stime_j").on('blur', function() {
	if($("#stime_j").val() == '') {
		$(this).next().text('服务结束时间不能为空').css('color', 'red').css('display', 'block');
		bol5 = false;
	} else {
		stime_j = $("#stime_j").val();
		$(this).next().hide();
		bol5 = true;
	};
});
//招募时间
var ztime_k;
var bol6 = false;
$("#ztime_k").on('blur', function() {
	if($("#ztime_k").val() == '') {
		$(this).next().next().text('招募开始时间不能为空').css('color', 'red').css('display', 'block');
		bol6 = false;
	} else {
		ztime_k = $("#ztime_k").val();
		bol6 = true;
	};
});
var ztime_j;
var bol77 = false;
$("#ztime_j").on('blur', function() {
	if($("#ztime_j").val() == '') {
		$(this).next().text('招募结束时间不能为空').css('color', 'red').css('display', 'block');
		bol7 = false;
	} else {
		ztime_j = $("#ztime_j").val();
		bol7 = true;
	};
});
//志愿者保障
var a_baozhang;
var bol8 = false;
$("#a_baozhang").on('blur', function() {
	if($("#a_baozhang").val() == '') {
		$(this).next().text('活动保障不能为空').css('color', 'red').css('display', 'block');
		bol8 = false;
	} else {
		a_baozhang = $("#a_baozhang").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		bol8 = true;
	};
});
//活动类型
$("#a_server_type input:checkbox").click(function() {
	var radio_len = $("#a_server_type input:checked").length;
	if(radio_len > 3) {
		$("#a_server_type").next().text('最多选择3个').css('color', 'red').css('display', 'block');
		return false;
	} else {
		$("#a_server_type").next().text('');
	}
})
//项目人数
var a_number;
var bol9 = false;
$("#a_number").on('blur', function() {
	if($("#a_number").val() == '') {
		$(this).next().text('活动保障不能为空').css('color', 'red').css('display', 'block');
		bol9 = false;
	} else {
		a_number = $("#a_number").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		bol9 = true;
	};
});
$('#creatActive').on('click', function() {
	var volunteerObj = {};
	if(bol0 && bol1 && bol2 && bol3 && bol4 && bol5 && bol6 && bol7 && bol8 && bol9 && bol10) {
		volunteerObj.uuid = uuid;
		volunteerObj.teamId = id;
		volunteerObj.loginType = is_team;
		volunteerObj.title = a_username;
		volunteerObj.address = h_addressName;
		volunteerObj.beginTime = atime_k;
		volunteerObj.endTime = atime_j;
		volunteerObj.serviceBeginTime = stime_k;
		volunteerObj.serviceEndTime = stime_j;
		volunteerObj.recruitBegin = ztime_k;
		volunteerObj.recruitEnd = ztime_j;
		volunteerObj.security = a_baozhang;
		volunteerObj.activityNum = a_number;
		volunteerObj.longitude = h_longitude;
		volunteerObj.latitude = h_latitude;
		volunteerObj.description = hd_description;
		//活动类型
		var fk = [];
		var ffkk = '';
		var sl = $("#a_server_type input:checked").length;
		if(sl == 0) {
			tips('请选择活动类型')
		} else {
			for(var i = 0; i < sl; i++) {
				fk.push($("#a_server_type input:checked").eq(i).attr('data-id'))
			}
			if(fk.length == 1) {
				ffkk = fk.join()
			} else if(fk.length > 1) {
				ffkk = fk.join(',')
			}
			volunteerObj.activityType = ffkk
		}
		//项目状态
//		var status = $("#a_zmtype input:checked").attr('data-id')
//		if(status == '' || status == undefined) {
//			tips('请选择活动状态')
//		} else {
			volunteerObj.status = 0;
//		}
		//报名范围
		var fanwei = $("#a_fanwei input:checked").val()
		if(fanwei == null || fanwei == '' || fanwei == undefined) {
			tips('请选择报名范围')
		} else if(fanwei == 1) {
			volunteerObj.scopeTeam = '';
		} else if(fanwei == 2) {
			var job_type = $("#job_type  option:selected").val();
			if(job_type == '请选择' || job_type == undefined) {
				tips('请选择报名团队');
				return false;
			} else {
				volunteerObj.scopeTeam = job_type;
			};
		}
		//服务区域
		var address_type = $("#address_type  option:selected").val();
		if(address_type == '请选择' || address_type == undefined) {
			tips('请选择服务区域');
			return false;
		} else {
			volunteerObj.areaId = address_type;
		};
		//服务对象
		var hy = [];
		var hhyy = '';
		var gt = $("#a_obj input:checked").length;
		if(gt == 0) {
			tips('请选择服务领域或行业')
		} else {
			for(var i = 0; i < gt; i++) {
				hy.push($("#a_obj input:checked").eq(i).val())
			}
			if(hy.length == 1) {
				hhyy = hy.join()
			} else if(hy.length > 1) {
				hhyy = hy.join(',')
			}
			volunteerObj.aimType = hhyy
		}
		//用户图像
		console.log(hdImg)
		if(hdImg == '' || hdImg == undefined) {
			tips('请上传活动封面')
			return false;
		} else {
			volunteerObj.imgUrl = hdImg;
		}
		//调取注册借口		
		$.ajax({
			type: "post",
			url: apicom + "/team/createActivity",
			async: false,
			dataType: "json",
			data: volunteerObj,
			success: function(res) {
				if(res.code == 200) {
					$('.mengban').css('display', 'block');
					$('.tips').text('活动创建成功')
					$('.btn_close').hide();
					$('.btn_close1').show();
				} else {
					$('.mengban').css('display', 'block');
					$('.tips').text(res.message)
				}
			},
			error: function(err) {

			}
		});
	} else {
		tips('请查看注册信息是否填写完整')
	}
})
//修改资料*********************************************************************************************
var v_username;
var reg3 = /^[\u4E00-\u9FA5\uf900-\ufa2d]{2,4}$/
var reg4 = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
var reg5 = /^1(3|4|5|7|8|9)\d{9}$/;
var t_bol0 = true;
v_username = $("#v_username").val();
$("#v_username").on('change', function() {
	if($("#v_username").val() == '') {
		$(this).next().text('团队名称不能为空').css('color', 'red').css('display', 'block');
		t_bol0 = false;
	} else {
		v_username = $("#v_username").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol0 = true;
	};
});
//志愿团体描述;
var description = $("#description").val();
var t_bol1 = true;
$("#description").on('change', function() {
	if($("#description").val() == '') {
		$(this).next().text('志愿团体不能为空').css('color', 'red').css('display', 'block');
		t_bol1 = false;
	} else {
		description = $("#description").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol1 = true;
	};
});
//主管单位名称
var competent_name = $('#competent_name').val();
var t_bol2 = true;
$("#competent_name").on('change', function() {
	if($("#competent_name").val() == '') {
		$(this).next().text('主管单位不能为空').css('color', 'red').css('display', 'block');
		t_bol2 = false;
	} else {
		competent_name = $("#competent_name").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol2 = true;
	};
});
//详细地址
var v_address;
var t_bol3 = true;
addressName = $("#v_address").val();
$("#v_address").on('change', function() {
	if($("#v_address").val() == '') {
		$(this).next().text('详细地址不能为空').css('color', 'red').css('display', 'block');
		t_bol3 = false;
	} else {
		v_address = $("#v_address").val();
		t_bol3 = true;
	};
});
//招募人数
var competent_num;
var t_bol4 = true;
competent_num = $("#competent_num").val()
$("#competent_num").on('change', function() {
	if($("#competent_num").val() == '') {
		$(this).next().text('招募人数不能为空').css('color', 'red').css('display', 'block');
		t_bol4 = false;
	} else {
		competent_num = $("#competent_num").val();
		t_bol4 = true;
	};
});
$("#v_server_type input:checkbox").click(function() {
	var radio_len = $("#v_server_type input:checked").length;
	if(radio_len > 4) {
		$("#v_server_type").next().text('最多选择4个').css('color', 'red').css('display', 'block');
		return false;
	} else {
		$("#v_server_type").next().text('');
	}
})
//联系人姓名
var contacts_name;
var t_bol5 = true;
contacts_name = $("#contacts_name").val()
$("#contacts_name").on('change', function() {
	if($("#contacts_name").val() == '') {
		$(this).next().text('联系人不能为空').css('color', 'red').css('display', 'block');
		t_bol5 = false;
	} else if(reg3.test($("#contacts_name").val()) == false) {
		$(this).next().text("联系人格式不正确").css('color', 'red').css('display', 'block');
		t_bol5 = false;
	} else {
		contacts_name = $("#contacts_name").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol5 = true;
	};
});

//联系人手机号码
var contacts_phone;
var t_bol6 = true;
contacts_phone = $("#contacts_phone").val();
$("#contacts_phone").on('change', function() {
	if($("#contacts_phone").val() == '') {
		$(this).next().text('手机号不能为空').css('color', 'red').css('display', 'block');
		t_bol6 = false;
	} else if(reg5.test($("#contacts_phone").val()) == false) {
		$(this).next().text("手机号格式不正确").css('color', 'red').css('display', 'block');
		t_bol6 = false;
	} else {
		contacts_phone = $("#contacts_phone").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol6 = true;
	};
});
//负责人姓名
var person_name;
var t_bol7 = true;
person_name = $("#person_name").val();
$("#person_name").on('change', function() {
	if($("#person_name").val() == '') {
		$(this).next().text('负责人不能为空').css('color', 'red').css('display', 'block');
		t_bol7 = false;
	} else if(reg3.test($("#person_name").val()) == false) {
		$(this).next().text("负责人姓名格式不正确").css('color', 'red').css('display', 'block');
		t_bol7 = false;
	} else {
		person_name = $("#person_name").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol7 = true;
	};
});
//负责人身份证
var person_IDcard;
var t_bol8 = true;
person_IDcard = $("#person_IDcard").val();
$("#person_IDcard").on('change', function() {
	if($("#person_IDcard").val() == '') {
		$(this).next().text('身份证号不能为空').css('color', 'red').css('display', 'block');
		t_bol8 = false;
	} else if(reg4.test($("#person_IDcard").val()) == false) {
		$(this).next().text("身份证号格式不正确，请重新输入").css('color', 'red').css('display', 'block');
		t_bol8 = false;
	} else {
		person_IDcard = $("#person_IDcard").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol8 = true;
	};
});
//负责人电话
var person_phone;
var t_bol9 = true;
person_phone = $("#person_phone").val();
$("#person_phone").on('change', function() {
	if($("#person_phone").val() == '') {
		$(this).next().text('负责人电话不能为空').css('color', 'red').css('display', 'block');
		t_bol9 = false;
	} else if(reg5.test($("#person_phone").val()) == false) {
		$(this).next().text("手机号格式不正确").css('color', 'red').css('display', 'block');
		t_bol9 = false;
	} else {
		person_phone = $("#person_phone	").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		t_bol9 = true;
	};
});
$('#keep_info').on('click', function() {
	var volunteerObj = {};
	if(t_bol0 && t_bol1 && t_bol2 && t_bol3 && t_bol4 && t_bol5 && t_bol6 && t_bol7 && t_bol8 && t_bol9) {
		volunteerObj.uuid = uuid;
		volunteerObj.loginId = id;
		volunteerObj.loginType = is_team;
		volunteerObj.name = v_username;
		volunteerObj.description = description;
		volunteerObj.supervisorName = competent_name;
		volunteerObj.teamNum = competent_num;
		volunteerObj.linkName = contacts_name;
		volunteerObj.telphone = contacts_phone;
		volunteerObj.personName = person_name;
		volunteerObj.person_idcard = person_IDcard;
		volunteerObj.personPhone = person_phone;
		volunteerObj.address = addressName;
		volunteerObj.longitude = longitude;
		volunteerObj.latitude = latitude;
		//单位类型
		var competent_type = $("#competent_type  option:selected").val();
		if(competent_type == '请选择' || competent_type == undefined) {
			tips('请选择主管单位类型');
			return false;
		} else {
			volunteerObj.supervisorType = competent_type;
		};
		//服务类型
		var fk = [];
		var ffkk = '';
		var sl = $("#v_server_type input:checked").length;
		if(sl == 0) {
			tips('请选择服务领域或行业')
		} else {
			for(var i = 0; i < sl; i++) {
				fk.push($("#v_server_type input:checked").eq(i).val())
			}
			if(fk.length == 1) {
				ffkk = fk.join()
			} else if(fk.length > 1) {
				ffkk = fk.join(',')
			}
			volunteerObj.serviceType = ffkk
		}
		//联系人QQ
		if($('#contacts_qq').val() == "") {
			volunteerObj.linkQq = $('#contacts_qq').val();
		} else {
			volunteerObj.linkQq = $('#contacts_qq').val();
		}
		//用户图像
		if(vtImg == '' || vtImg == undefined) {
			volunteerObj.imgUrl = $('#vt_img').attr('src');
		} else {
			volunteerObj.imgUrl = vtImg;
		}
		//调取注册借口		
		$.ajax({
			type: "post",
			url: apicom + "/user/editMemberInfo",
			async: false,
			dataType: "json",
			data: volunteerObj,
			success: function(res) {
				if(res.code == 1) {
					$('.mengban').css('display', 'block');
					$('.tips').text('修改资料成功')
//					location.reload()
				} else {
					$('.mengban').css('display', 'block');
					$('.tips').text(res.message)
				}
			},
			error: function(err) {

			}
		});
	} else {
		tips('请查看注册信息是否填写完整')
	}
})
//修改密码**********************************************************************************
var v_passward;
var reg1 = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
var pbol_1 = false;
$("#v_passward").on('blur', function() {
	if($("#v_passward").val() == '') {
		$(this).next().text('密码不能为空').css('color', 'red').css('display', 'block');
		pbol_1 = false;
	} else if(reg1.test($("#v_passward").val()) == false) {
		$(this).next().text("密码格式不正确，请重新输入").css('color', 'red').css('display', 'block');
		pbol_1 = false;
	} else {
		v_passward = $("#v_passward").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		pbol_1 = true;
	};
});
var v_passward1;
var reg1 = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
var pbol_2 = false;
$("#v_passward1").on('blur', function() {
	if($("#v_passward1").val() == '') {
		$(this).next().text('密码不能为空').css('color', 'red').css('display', 'block');
		pbol_2 = false;
	} else if(reg1.test($("#v_passward1").val()) == false) {
		$(this).next().text("密码格式不正确，请重新输入").css('color', 'red').css('display', 'block');
		pbol_2 = false;
	} else {
		v_passward1 = $("#v_passward1").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		pbol_2 = true;
	};
});
var v_passward2;
var reg1 = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
var pbol_3 = false;
$("#v_passward2").on('blur', function() {
	if($("#v_passward2").val() == '') {
		$(this).next().text('密码不能为空').css('color', 'red').css('display', 'block');
		pbol_3 = false;
	} else if(reg1.test($("#v_passward2").val()) == false) {
		$(this).next().text("密码格式不正确，请重新输入").css('color', 'red').css('display', 'block');
		pbol_3 = false;
	} else {
		v_passward2 = $("#v_passward2").val();
		$(this).next().text('输入正确').css('color', 'limegreen').css('display', 'block');
		pbol_3 = true;
	};
});
$('#ch_password').on('click', function() {
	var relpassObj = {};
	if(pbol_1 && pbol_2 && pbol_3) {
		relpassObj.uuid = uuid;
		relpassObj.loginId = id;
		relpassObj.loginType = is_team;
		relpassObj.oldPassword = v_passward;
		relpassObj.newPassword = v_passward2;
		//调取注册借口		
		$.ajax({
			type: "post",
			url: apicom + "/user/editPassword",
			async: false,
			dataType: "json",
			data: relpassObj,
			success: function(res) {
				if(res.code == 200) {
					tips('密码修改成功');
					$("#v_passward2").val('');
					$("#v_passward1").val('');
					$("#v_passward").val('');

				} else {
					tips(res.message)
				}
			},
			error: function(err) {

			}
		});
	} else {
		tips('请查看注册信息是否填写完整')
	}
})
//团队成员*********************************************************************************
//团队成员筛选
var mNumber = '';
var mName = '';
var mClassId = '';
//搜索
$('#search_prod').on('click', function() {
	var productNum = $('#pro_num').val();
	var productName = $('#pro_name').val();
	var className = $("#pro_type  option:selected").val();
	if(productNum == '' || productNum == undefined) {
		productNum = ''
	}
	if(productName == '' || productName == undefined) {
		productName = ''
	}
	mNumber = productNum;
	mName = productName;
	mClassId = className
	memberList(1, mNumber, mName, mClassId, true)
})
$('#reset').on('click', function() {
	$('#pro_num').val('');
	$('#pro_name').val('');
	$("#pro_type").find("option[value='']").attr("selected", true);
	memberList(1, '', '', '', true)
})
memberList(1, mNumber, mName, mClassId, true)

function memberList(page, mNumber, mName, mClassId, init) {
	var hdObj = {
		uuid: uuid,
		username: name,
		loginId: id,
		loginType: is_team,
		memberNumber: mNumber,
		memberName: mName,
		status: mClassId,
		pageNum: page,
		pageSize: 7,
	}
	$.ajax({
		type: "post",
		url: apicom + '/team/getTeamMemberList',
		async: true,
		data: hdObj,
		success: function(res) {
			if(typeof res == 'string') {
				res = JSON.parse(res);
			}
			if(res.code == 200) {
				var dataScourse = res.data;
				if(res.pages == 1) {
					$("#jf_page").hide();
					//					return false;
					jiegou(dataScourse);
				} else {
					jiegou(dataScourse);
					$("#jf_page").show();
					/* 分页 */
					if(init == true) {
						$("#jf_page").createPage({
							pageNum: res.pages, //总页码
							current: 1, //当前页
							shownum: 7, //每页显示个数
							showPageNum: false, //显示总页数
							showToPage: false, //显示跳转页码
							backfun: function(e) {
								memberList(e.current, mNumber, mName, mClassId, false);
							}
						});
					}
				}

			} else {
//				tips('数据暂无')
			}
		},
		error: function(err) {
		}
	})
}

function jiegou(content) {
	var ss = '';
	for(var i = 0; i < content.length; i++) {
		ss += '<tr><td>' + content[i].number + '</td><td>' + content[i].realName + '</td><td>' + content[i].phone + '</td><td>' + content[i].joinTime + '</td><td>' + content[i].auditStatis + '</td>'
		if(content[i].auditStatus == 0) {
			ss += '<td><span data-status="1"  data-id="' + content[i].id + '" class="caozuo">通过</span>&nbsp;&nbsp;<span data-status="2"  data-id="' + content[i].id + '" class="caozuo">拒绝</span></td></tr>'
		} else if(content[i].auditStatus == 1) {
			ss += '<td><span data-status="3"  data-id="' + content[i].id + '" class="caozuo">移除</span></td></tr>'
		} else if(content[i].auditStatus == 2) {
			ss += '<td><span data-status="3"  data-id="' + content[i].id + '" class="caozuo">移除</span></td></tr>'
		} else if(content[i].auditStatus == 3) {
			ss += '<td><span data-status="4"  data-id="' + content[i].id + '" class="caozuo">删除</span></td></tr>'
		}
	}
	$('.teamMember').html(ss)
}
//团队成员操作
$('#jf_table').on('click', '.caozuo', function() {
	var status = $(this).attr('data-status');
	var id = $(this).attr('data-id');
	caozuo(status, id);
	memberList(1, mNumber, mName, mClassId, true)

})

function caozuo(status, id) {
	$.ajax({
		type: "post",
		url: apicom + "/team/auditOrDeleteTeamMember",
		async: true,
		data: {
			uuid: uuid,
			username: name,
			loginId: id,
			loginType: is_team,
			status: status,
			id: id
		},
		success: function(res) {
			if(res.code == 200) {
				$('.mengban').css('display', 'block');
				$('.tips').text('操作成功')
				memberList(1, mNumber, mName, mClassId, true)
			}

		},
		error: function(err) {
			console.log(err);
		}

	});
}
//团队活动*****************************************************************************************************
//团队活动筛选
$('.mineTeam_type p').on('click', function() {
	$(this).addClass('click_type');
	$(this).siblings().removeClass('click_type');
	var type = $(this).attr('data-type')
	ActiveList(1, type, true)
})

ActiveList(1, '0', true)

function ActiveList(page, type, init) {
	var hdObj = {
		uuid: uuid,
		loginId: id,
		loginType: is_team,
		type:type,
		pageNum: page,
		type: type,
		pageSize: 5,
	}
	$.ajax({
		type: "post",
		url: apicom + '/user/myActivity',
		async: true,
		data: hdObj,
		success: function(res) {
			if(typeof res == 'string') {
				res = JSON.parse(res);
			}
			if(res.code == 200) {
				var dataScourse = res.data;
				if(res.pages == 1) {
					$("#hd_page").hide();
					//					return false;
					huodong(dataScourse);
				} else {
					huodong(dataScourse);
					$("#hd_page").show();
					/* 分页 */
					if(init == true) {
						$("#hd_page").createPage({
							pageNum: res.pages, //总页码
							current: 1, //当前页
							shownum: 5, //每页显示个数
							showPageNum: false, //显示总页数
							showToPage: false, //显示跳转页码
							backfun: function(e) {
								ActiveList(e.current, type, false);
							}
						});
					}
				}

			} else {
//				tips('数据暂无')
			}
		},
		error: function(err) {
			console.log(err)
		}
	})
}

function huodong(content) {
	var ss = '';
	for(var i = 0; i < content.length; i++) {
		ss += '<tr><td>' + content[i].title + '</td><td>' + content[i].address + '</td><td>' + content[i].beginTime + '</td><td>' + content[i].serviceHour + '</td>'
		if(content[i].isMy == 1) {
			ss += '<td><span>' + content[i].memberNum + '</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span data-id="' + content[i].activityId + '" class="memberNum">查看</span></td><td>' + content[i].status + '</td></tr>'
		} else if(content[i].isMy == null) {
			ss += '<td><span>' + content[i].memberNum + '</span></td><td>' + content[i].status + '</td></tr>'
		}
	}
	$('.hd_list').html(ss)
}

//查看成员列表
var teamActiveId;
$('.hd_list').on('click', '.memberNum', function() {
	$('#team_active').hide();
	$('#people_list').show();
	teamActiveId = $(this).attr('data-id');
	teammember(teamActiveId, zNumber, zName, zClassId);
});
//团队成员筛选
var zNumber = '';
var zName = '';
var zClassId = '';
//搜索
$('#search_zyz').on('click', function() {
	var productNum = $('#zyz_num').val();
	var productName = $('#zyz_name').val();
	var className = $("#zyz_type  option:selected").val();
	if(productNum == '' || productNum == undefined) {
		productNum = ''
	}
	if(productName == '' || productName == undefined) {
		productName = ''
	}
	zNumber = productNum;
	zName = productName;
	zClassId = className
	teammember(teamActiveId, zNumber, zName, zClassId)
})
$('#reset_zyz').on('click', function() {
	$('#zyz_num').val('');
	$('#zyz_name').val('');
	$("#zyz_type").find("option[value='']").attr("selected", true);
	teammember(teamActiveId);
})

function teammember(Aid, zNumber, zName, zClassId) {
	var hdObj = {
		uuid: uuid,
		activityId: Aid,
		loginType: is_team,
		number: zNumber,
		realName: zName,
		status: zClassId
	}
	$.ajax({
		type: "post",
		url: apicom + "/user/getActivityMemberInfo",
		async: true,
		data: hdObj,
		success: function(res) {
			var content = res.data;
			var ss = ''
			for(var i = 0; i < content.length; i++) {
				ss += '<tr><td>' + content[i].number + '</td><td>' + content[i].realName + '</td><td>' + content[i].phone + '</td><td>' + content[i].joinTime + '</td>'
				if(content[i].auditStatus == 0) {
					ss += '<td>待审核</td><td><span data-status="2"  data-id="' + content[i].id + '" class="caozuo1">通过</span>&nbsp;&nbsp;<span data-status="3"  data-id="' + content[i].id + '" class="caozuo1">拒绝</span></td></tr>'
				} else if(content[i].auditStatus == 1) {
					ss += '<td>正常</td><td><span data-status="1"  data-id="' + content[i].id + '" class="caozuo1">移除</span></td></tr>'
				} else if(content[i].auditStatus == 2) {
					ss += '<td>已拒绝</td><td><span data-status="4"  data-id="' + content[i].id + '" class="caozuo1">删除</span></td></tr>'
				} else if(content[i].auditStatus == 3) {
					ss += '<td>已退出</td><td><span data-status="4"  data-id="' + content[i].id + '" class="caozuo1">删除</span></td></tr>'
				}
			}
			$('.peopleList').html(ss);
		},
		error: function(err) {
			console.log(err)
		}
	});
}
//活动成员操作
$('.peopleList').on('click', '.caozuo1', function() {
	var status = $(this).attr('data-status');
	var id = $(this).attr('data-id');
	caozuo1(status, id);
	teammember(teamActiveId, '', '', '');

})

function caozuo1(status, id) {
	$.ajax({
		type: "post",
		url: apicom + "/user/operate",
		async: true,
		data: {
			uuid: uuid,
			loginType: is_team,
			type: status,
			operateId: id
		},
		success: function(res) {
			if(res.code == 200) {
				$('.mengban').css('display', 'block');
				$('.tips').text('操作成功')
			}

		},
		error: function(err) {
			console.log(err);
		}

	});
}
//时长审批*******************************************************************************
var activeName = '';
//搜索
$('#search_time').on('click', function() {
	var productNum = $('#activeName').val();
	if(productNum == '' || productNum == undefined) {
		productNum = ''
	}
	activeName = productNum;
	timList(activeName)
})
timList()

function timList(activeName) {
	var hdObj = {
		uuid: uuid,
		loginId: id,
		loginType: is_team,
		activityName:activeName
	}
	$.ajax({
		type: "post",
		url: apicom + "/user/getApprovalList",
		async: true,
		data: hdObj,
		success: function(res) {
			var content = res.data;
			var ss = ''
			for(var i = 0; i < content.length; i++) {
				ss += '<tr><td><input type="checkbox" name="" id="" value="' + content[i].id + '" /></td><td>' + content[i].memberNumber + '</td><td>' + content[i].memberName + '</td><td>' + content[i].telPhone + '</td><td>' + content[i].activityName + '</td><td>' + content[i].remark + '</td><td>' + content[i].applyTime + '</td><td>' + content[i].createTime + '</td></tr>'
			}
			$('.timeList').html(ss);
		},
		error: function(err) {
			console.log(err)
		}
	});
}
//全选，取消全选	
$('#timechecks').on('click', function() {
	if($(this).is(":checked")) {
		$('.timeList input').prop('checked', true);
	} else {
		$('.timeList input').prop('checked', false);
	}
})
//获取选中人的id

$('#time_agree').on('click', function() {
	var timeids = '';
	var chooseid = [];
	var gt = $(".timeList input:checked").length;
	if(gt == 0) {
		tips('请选择操作人')
		return false;
	} else {
		for(var i = 0; i < gt; i++) {
			chooseid.push($(".timeList input:checked").eq(i).val())
		}
		if(chooseid.length == 1) {
			timeids = chooseid.join()
		} else if(chooseid.length > 1) {
			timeids = chooseid.join(',')
		}
	}
	timeagree(1, timeids);

})
$('#time_refuse').on('click', function() {
	var timeids = '';
	var chooseid = [];
	var gt = $(".timeList input:checked").length;
	if(gt == 0) {
		tips('请选择操作人')
		return false;
	} else {
		for(var i = 0; i < gt; i++) {
			chooseid.push($(".timeList input:checked").eq(i).val())
		}
		if(chooseid.length == 1) {
			timeids = chooseid.join()
		} else if(chooseid.length > 1) {
			timeids = chooseid.join(',')
		}
	}
	timeagree(2, timeids);
})

function timeagree(auditStatus, operateId) {
	$.ajax({
		type: "post",
		url: apicom + "/user/updateApprovalStatus",
		async: true,
		data: {
			auditStatus: auditStatus,
			operateId: operateId
		},
		success: function(res) {
			if(res.code == 200) {
				$('.mengban').css('display', 'block');
				$('.tips').text('操作成功');
				timList();

			} else {
				$('.mengban').css('display', 'block');
				$('.tips').text(res.message)
			}
		}
	});
}
//function ids(){	
//		var timeids = '';
//		var chooseid = [];
//		var gt = $(".timeList input:checked").length;
//		if(gt == 0) {
//			tips('请选择操作人')
//			return false;
//		} else {
//			for(var i = 0; i < gt; i++) {
//				chooseid.push($(".timeList input:checked").eq(i).val())
//			}
//			if(chooseid.length == 1) {
//				timeids = chooseid.join()
//			} else if(chooseid.length > 1) {
//				timeids = chooseid.join(',')
//			}
//		}
//	}
//站内信*********************************************************************************************
//站内信成员筛选
var msgNumber = '';
var msgName = '';
var msgphone = '';
//搜索
$('#zyz_search').on('click', function() {
	var productNum = $('#zyzNum').val();
	var productName = $('#zyzName').val();
	var className = $("#zyzPhone").val();
	if(productNum == '' || productNum == undefined) {
		productNum = ''
	}
	if(productName == '' || productName == undefined) {
		productName = ''
	}
	if(className == '' || className == undefined) {
		className = ''
	}
	msgNumber = productNum;
	msgName = productName;
	msgphone = className
	msgMemberlist(msgNumber, msgName, msgphone)
})
$('#zyzReset').on('click', function() {
	$('#zyzNum').val('');
	$('#zyzName').val('');
	$("#zyzPhone").val('');
	msgMemberlist();
})
$('.choose_people').on('click', function() {
	$('.mengban1').css('display', 'block')
	msgMemberlist()
})

function msgMemberlist(msgNumber, msgName, msgphone) {
	var hdObj = {
		number: msgNumber,
		name: msgName,
		phone: msgphone
	}
	$.ajax({
		type: "post",
		url: apicom + "/team/getMemberListInMessage",
		async: true,
		data: hdObj,
		success: function(res) {
			var content = res.data;
			var ss = ''
			for(var i = 0; i < content.length; i++) {
				ss += '<tr><td><input type="checkbox" name="" id="" value="' + content[i].id + '" /></td><td>' + content[i].number + '</td><td>' + content[i].realName + '</td><td>' + content[i].phone + '</td></tr>'
			}
			$('.send_list').html(ss);
		},
		error: function(err) {
			console.log(err)
		}
	});
}
//全选，取消全选	
$('#allchecks').on('click', function() {
	if($(this).is(":checked")) {
		$('.send_list input').prop('checked', true);
	} else {
		$('.send_list input').prop('checked', false);
	}
})
//获取选中人的id
var chooseids = '';
$('#btn_yes').on('click', function() {
	var chooseid = [];
	var gt = $(".send_list input:checked").length;
	if(gt == 0) {
		tips('请选择收件人')
		return false;
	} else {
		for(var i = 0; i < gt; i++) {
			chooseid.push($(".send_list input:checked").eq(i).val())
		}
		if(chooseid.length == 1) {
			chooseids = chooseid.join()
		} else if(chooseid.length > 1) {
			chooseids = chooseid.join(',')
		}
	}
	$('.mengban1').hide();
})
//发送站内信
$('#sendmsg').on('click', function() {
	if($('#send_title').val() == '') {
		tips('请输入站内信标题')
	}
	//	if($('#send_title').val()==''){
	//		tips('请选择收件人')
	//	}
	if($('#msg_detail').val() == '') {
		tips('请输入站内信内容')
	}
	$.ajax({
		type: "post",
		url: apicom + "/sysmessage/sendMessage",
		async: true,
		data: {
			uuid: uuid,
			loginId: id,
			loginType: is_team,
			username: name,
			title: $('#send_title').val(),
			content: $('#msg_detail').val(),
			ids: chooseids
		},
		success: function(res) {
			if(res.code == 200) {
				$('.mengban').css('display', 'block');
				$('.tips').text('发送成功');
				$('#send_title').val('')
				$('#msg_detail').val('')

			} else {
				$('.mengban').css('display', 'block');
				$('.tips').text(res.message)
			}

		},
		error: function(err) {
			console.log(err);
		}

	});
})

//获取团队列表
$.ajax({
	type: "post",
	url: apicom + "/team/getTeamList",
	async: true,
	success: function(res) {
		var data = res.data;
		var ss = '';
		for(var i = 0; i < data.length; i++) {
			ss += '<option value="' + data[i].teamId + '">' + data[i].name + '</option>'
		}
		$("#job_type").html(ss);
	},
	error: function(err) {

	}
});
//获取服务区域
$.ajax({
	type: "post",
	url: apicom + "/area/getAreaInfo",
	async: true,
	success: function(res) {
		var data = res.data;
		var ss = '';
		for(var i = 0; i < data.length; i++) {
			ss += '<option value="' + data[i].id + '">' + data[i].name + '</option>'
		}
		$("#address_type").html(ss);
	},
	error: function(err) {

	}
});
//关闭按钮
$('.btn_close').on('click', function() {
	$('.mengban').css('display', 'none');
})
$('.btn_close1').on('click', function() {
	$('.mengban').css('display', 'none');
	window.location.href = 'liebiao.html?type=1'
})
$('.close_s').on('click', function() {
	$('.mengban').css('display', 'none');
})
$('.close_s1').on('click', function() {
	$('.mengban1').css('display', 'none');
})